import request from '@/utils/request'

// 查询圈子成员关系列表
export function listCircleMember(query) {
  return request({
    url: '/circle/member/memberList/' + query.circleId,
    method: 'get',
    params: {
      pageNum: query.pageNum,
      pageSize: query.pageSize
    }
  })
}

// 查询圈子成员关系详细
export function getCircleMember(id) {
  return request({
    url: '/circle/member/' + id,
    method: 'get'
  })
}

// 新增圈子成员关系
export function addCircleMember(data) {
  return request({
    url: `/circle/member/add/${data.circleId}/${data.userId}/${data.memberRole}`,
    method: 'post'
  })
}

// 修改圈子成员角色
export function updateCircleMemberRole(data) {
  return request({
    url: '/circle/member/role',
    method: 'put',
    data: data
  })
}

// 移除圈子成员
export function removeCircleMember(row) {
  return request({
    url: '/circle/member/remove/' + row.circleId + '/' + row.userId,
    method: 'delete'
  })
}

// 获取当前用户在圈子中的角色
export function getCurrentUserRole(circleId) {
  return request({
    url: '/circle/member/currentUserRole/' + circleId,
    method: 'get'
  })
}

// 将用户加入黑名单
export function addToBlacklist(data) {
  return request({
    url: `/circle/member/blacklist/${data.circleId}/${data.userId}/1`,
    method: 'put'
  })
}

// 将用户从黑名单移除
export function removeFromBlacklist(data) {
  return request({
    url: `/circle/member/blacklist/${data.circleId}/${data.userId}/0`,
    method: 'put'
  })
}

// 获取圈子黑名单列表
export function listBlacklist(query) {
  return request({
    url: `/circle/member/blacklist/list/${query.circleId}`,
    method: 'get',
    params: {
      pageNum: query.pageNum,
      pageSize: query.pageSize
    }
  })
}